package main
import(
	"fmt"
	"time"
	"sync"
)

func main() {
	ch := make(chan int, 1000)
	wg := sync.WaitGroup{}
    wg.Add(1)
	go func() {
		defer wg.Done()
		for i := 0; i < 10; i++ {
			ch <- i
		}
	}()

	wg.Wait()

	go func() {
		for {
			a, ok := <-ch
			if !ok {
				fmt.Println("close")
				return
			}
			fmt.Println("a: ", a)
		}
	}()

	close(ch)
	fmt.Println("ok")
	time.Sleep(time.Second * 100)

	
	var iTmp int
	fmt.Printf("iTmp=%v\n", iTmp)
}
 

 
